#include<stack>
using namespace std;


class CQueue {
public:
        stack<int> sk1;
        stack<int> sk2;
    CQueue() {
        
    }
    
    void appendTail(int value) {
        if(sk1.empty()){
            sk1.push(value);
            return;
        }
        while (!sk1.empty())
        {
            sk2.push(sk1.top());
            sk1.pop();
        }

        sk1.push(value);
        while (!sk2.empty())
        {
            sk1.push(sk2.top());
            sk2.pop();
        }
    }
    
    int deleteHead() {
        if (!sk1.empty()){
            int res = sk1.top();
            sk1.pop();
            return res;
        }
        return -1;
    }
};
/**
 * 最优解
 * 
 */
class CQueue {
private:
    stack<int> inStack, outStack;

    void in2out() {
        while (!inStack.empty()) {
            outStack.push(inStack.top());
            inStack.pop();
        }
    }

public:
    CQueue() {}

    void appendTail(int value) {
        inStack.push(value);
    }

    int deleteHead() {
        if (outStack.empty()) {
            if (inStack.empty()) {
                return -1;
            }
            in2out();
        }
        int value = outStack.top();
        outStack.pop();
        return value;
    }
};